/*
 * ps2.h
 *
 *  Created on: Nov 19, 2021
 *      Author: zz
 */

#ifndef APP_PS2_H_
#define APP_PS2_H_


#include "main.h"
#include "stm32f1xx_it.h"

//普通按键位掩码
typedef enum {
	PS_SELECT = 0,
	PS_L3,
	PS_R3,
	PS_START,
	PS_UP,
	PS_RIGHT,
	PS_DOWN,
	PS_LEFT,
	PS_L2,
	PS_R2,
	PS_L1,
	PS_R1,
	PS_DELTA,
	PS_CIRCLE,
	PS_CROSS,
	PS_SQUARE,
	PS_BTN_COUNT
}PS_BTN;

//模拟扩展按键 偏移量
typedef enum {
	PS_A_RX = 5,
	PS_A_RY = 6,
	PS_A_LX = 7,
	PS_A_LY = 8
}PS_ANALOG_OFFSET;

//PS2初始化
void ps2_init();

//PS2处理，周期执行, 内部延时，不能放定时器回调中，影响时序, 最好置于单独的线程或与其他线程合并
void ps2_proc(void* arg);

//PS2获取按键信息
int ps2_get_btn(PS_BTN no);
int ps2_get_analog(PS_ANALOG_OFFSET no);

// PS2获取模式
// 0-标准 1-扩展 -1-不可用
int ps2_get_mode();

void ps2_dump();

#endif /* APP_PS2_H_ */
